package com.ama.controller;

import com.ama.service.EmployeeService;
import com.ama.utils.SpringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@Controller
public class InformAgreedController {
    @RequestMapping("/informAgreed")
    public void informAgreed(HttpServletResponse response, HttpServletRequest request) throws IOException {
        long id = Long.parseLong(request.getParameter("id"));
        long isAgreed = Long.parseLong(request.getParameter("isAgreed"));
        SpringUtils.getBean(EmployeeService.class).update(isAgreed,id);
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<script>");
        out.println("alert('发送成功！')");
        out.println("window.open ('"+request.getContextPath()+"/c_index.jsp','_top')");
        out.println("</script>");
        out.println("</html>");
        out.flush();
        out.close();
    }

}
